<template>
  <div class="vivid-skeleton-loader" :class="{ 'is-loading': loading }">
    <template v-if="loading">
      <slot name="skeleton">
        <vi-skeleton v-bind="$attrs" />
      </slot>
    </template>
    <template v-else>
      <slot></slot>
    </template>
  </div>
</template>

<script lang="ts">
import ViSkeleton from './ViSkeleton.vue'

export default {
  name: 'ViSkeletonLoader',
  components: { ViSkeleton },
  inheritAttrs: false,
  props: {
    loading: {
      type: Boolean,
      default: true
    }
  }
}
</script>

<style scoped>
.vivid-skeleton-loader.is-loading {
  pointer-events: none;
  user-select: none;
}
</style>
